import java.util.*;
import org.jdom.*;
import org.jdom.filter.*;
import org.jdom.input.*;


public class JDOMSolution {
    public static void main(String[] args) {
	//args[0] is the XHTML document
	try {
		Date start = new Date();
	
		int count = 0;
	    SAXBuilder b = new SAXBuilder();
	    Document d = b.build(args[0]);
	    Namespace ns = Namespace.getNamespace("http://www.w3.org/1999/xhtml");
	    Filter f = new ElementFilter("input", ns);
	    Iterator i = d.getDescendants(f);
	    
	    while(i.hasNext()){
	    	Object s = i.next();
	    	count++;
	    }
	    
	    Date finish = new Date();
	    long finishTime = finish.getTime() - start.getTime();
	    System.out.println("JDOMSolution: Number of input elements is "+count);
	    System.out.println("JDOMSolution: Time was "+ finishTime + "ms");
	}
	catch(Exception e) {
	    System.err.println(e);
	}
    }
}